package com.it.tydic.estate.module.controller.cwgl;

import com.it.tydic.estate.common.annotation.ControllerDesc;
import com.it.tydic.estate.common.aop.CodeMsg;
import com.it.tydic.estate.common.aop.Result;
import com.it.tydic.estate.common.constants.LogConstants;
import com.it.tydic.estate.module.controller.common.LoginController;
import com.it.tydic.estate.module.model.inner.TbCwda;
import com.it.tydic.estate.module.service.TbCwdaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import tk.mybatis.mapper.util.StringUtil;

import java.util.List;
import java.util.Map;

/**
 * @description:   车位档案管理Controller
 * @author: zhangshuo
 * @createDate: 2020/03/04
 * @version: 1.0
 */
//@Api(value = "车位档案管理数据接口",description = "车位管理———车位档案管理 ")
@Api(tags ="车位管理———车位档案管理")
@RestController("/tbcwda")
public class TbCwdaController {
    @Autowired
   private TbCwdaService tbCwdaService;
    private static final Logger logger=  LoggerFactory.getLogger(LoginController.class);

    /*车位档案模糊查询*/
    @PostMapping ("/selectBydaPage")
    @ApiOperation(value = "条件查询车位档案", notes = "条件查询车位档案")
    public Result selectBydaPage(@RequestBody Map<String,Object> tbCwda) {
        logger.info("sucess");
        return tbCwdaService.selectBydaPage(tbCwda);
    }
    /*车位档案批量删除*/
    @PostMapping ("/deleteByTbCwda")
    @ControllerDesc(description = LogConstants.delete_data)
    @ApiOperation(value = "车位档案批量删除", notes = "车位档案批量删除")
    public Result deleteByTbCwda(@RequestBody List<String> list) {
        logger.info("sucess");
        return tbCwdaService.deleteByTbCwda(list);
    }


    /*车位档案新增或修改*/
    @PostMapping ("/insertTbCwdaOrUpdata")
    @ControllerDesc(description = LogConstants.addOrUpdate_data)
    @ApiOperation(value = "车位档案新增或修改", notes = "车位档案新增或修改")
    public Result insertTbCwdaOrUpdata(@RequestBody TbCwda tbCwda) {
        logger.info("sucess");
        return tbCwdaService.insertTbCwdaOrUpdata(tbCwda);
    }
    @PostMapping ("/selectCwByGlc")
    @ApiOperation(value = "根据管理处查询车位区域", notes = "根据管理处查询车位区域")
    public Result selectCwByGlc(@RequestBody Map<String,Object> map) {
        logger.info("sucess");
        return tbCwdaService.selectCwByGlc(map);
    }
    @PostMapping ("/selectCwdaByGlc")
    @ApiOperation(value = "根据车位区域查询车位档案", notes = "根据车位区域查询车位档案")
    public Result selectCwdaByGlc(@RequestBody Map<String,Object> map) {
        logger.info("sucess");
        return tbCwdaService.selectCwdaByGlc(map);
    }

    /**
     * 根据用户id获取区域导航树
     * @param userId 用户id
     * @return
     */
    @GetMapping ("/findRNAVTreeByUserId/{userId}")
    @ApiOperation(value = "根据用户id获取区域导航树", notes = "根据用户id获取区域导航树")
    @ApiImplicitParam(name = "userId", value = "用户id", paramType = "path", required = true, dataType = "String")
    public Result findRNAVTreeByUserId(@PathVariable String userId) {
        if (StringUtil.isEmpty(userId)) {
            Result.error(CodeMsg.EMPTY_PARAM_ERROR);
        }
        return tbCwdaService.findRNAVTreeByUserId(userId);
    }

    /**
     * 根据用户id获取车位收费导航树
     * @param userId 用户id
     * @return
     */
    @GetMapping ("/findCwDhreeByUserId/{userId}")
    @ApiOperation(value = "根据用户id获取车位收费导航树", notes = "根据用户id获取车位收费导航树")
    @ApiImplicitParam(name = "userId", value = "用户id", paramType = "path", required = true, dataType = "String")
    public Result findCwDhreeByUserId(@PathVariable String userId) {
        if (StringUtil.isEmpty(userId)) {
            Result.error(CodeMsg.EMPTY_PARAM_ERROR);
        }
        return tbCwdaService.findCwDhreeByUserId(userId);
    }



}
